package com.bop.dehong.more;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import cn.jpush.a.a.b;

import com.bop.dehong.R;
import com.bop.dehong.base.BaseActivity;
import com.bop.dehong.base.TopManager;
import com.bop.dehong.config.Config;
import com.bop.dehong.webview.WebViewActivity;

/**
 * 关于德鸿
* @author TangWenhan
*/
public class AboutDeHongActivity extends BaseActivity{
	
	private TextView versionCodeTV;
	
	@Override
	protected void initTop() {
		View mView = getView(R.id.top);
		TopManager manager = new TopManager(mView);
		manager.setTitle(R.string.about_dehong);
		manager.setLeftImageVisibility(View.VISIBLE);
	}

	@Override
	protected void initUI() {
		versionCodeTV = getView(R.id.textView1);
	}

	@Override
	protected void initData() {
		versionCodeTV.setText("版本号：V "+ getVersionName());
//		versionCodeTV.setText("版本名称（号）：V "+ getVersionName());
	}
	public void goWeb(View v){
		Intent intent = new Intent(this,WebViewActivity.class);
		intent.putExtra(Config.GO_BACK, true);
		switch (v.getId())
		{
		case R.id.company_web_ll:
			intent.putExtra("title", "德鸿");
			intent.putExtra("url", getResources().getString(R.string.dehong_m_url));
			break;

		case R.id.aboutus_web_ll:
			intent.putExtra("title", "关于德鸿");
			intent.putExtra("url", getResources().getString(R.string.dehong_aboutus_url));
			break;
		}
		startActivity(intent);
	}
	private String getVersionName()  
	{  	
	        // 获取packagemanager的实例  
	        PackageManager packageManager = getPackageManager();  
	        // getPackageName()是你当前类的包名，0代表是获取版本信息  
	        PackageInfo packInfo;
	        String version = "";
//	        int versionCode = 0;
			try {
				packInfo = packageManager.getPackageInfo(getPackageName(),0);
				version = packInfo.versionName; 
//				versionCode = packInfo.versionCode;
			} catch (NameNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}  
//			 return version + " (" +versionCode + ")";  
	        return version;  
	} 
	
	@Override
	protected int getContentViewId() {
		TAG = getClass().getName();
		return R.layout.act_about_dehong;
	}

	@Override
	public void onClick(View v)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id)
	{
		// TODO Auto-generated method stub
		
	}

}

